package main.java.tmi.product.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.product.service.ProductVO;

import org.springframework.stereotype.Repository;

/**
 * Product Data Access Object (cust Table)
 *
 * @author min™
 * @since 2012. 04. 24
 */
@Repository
public class ProductDAO extends AbstractDao {
	
	/**
	 * Product search
	 * @return List<ProductVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public List<ProductVO> getProductView(Map<String,String> param) throws SQLException {
				
		return (List<ProductVO>) list("ProductDAO.getProductView", param);
	}
	
	/**
	 * Product search
	 * @return List<ProductVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public int getProductViewCount(Map<String,String> param) throws SQLException {
		return Integer.parseInt((String) getSqlMapClientTemplate().queryForObject("ProductDAO.getProductViewCount", param));
	}
	
	/**
	 * Product search
	 * @return List<ProductVO>
	 * @throws SQLException 
	 */
	@SuppressWarnings("unchecked")
	public Map<String,String>  getProductDetailView(Map<String,String> param) throws SQLException {
		Map<String,String> returnMap ;
        returnMap = (Map<String,String>) selectByPk("ProductDAO.getProductDetailView", param);
        
        return returnMap;
	}
	
	/**
	 * Product save
	 * @return void
	 * @throws SQLException 
	 */
	public void addProduct(Map<String,String> param) throws SQLException {
		insert("ProductDAO.addProduct", param);
	}
	
	/**
	 * Product modify
	 * @return void
	 * @throws SQLException 
	 */
	public void modifyProduct(Map<String,String> param) throws SQLException {
		insert("ProductDAO.modifyProduct", param);
	}
	
	/**
	 * Product del
	 * @return void
	 * @throws SQLException 
	 */
	public void delProduct(Map<String,String> param) throws SQLException {
		insert("ProductDAO.delProduct", param);
	}	
}
